<template>
  <div id="app">
    <navigation>
      <router-view />
    </navigation>
  </div>
</template>

<script>
import { checkCompanyLogin, checkPersonLogin, getCompanyAutoLoginData, getPersonAutoLoginData, setToken } from './util/session';
import { returnToPhoneWithData } from "@/util/phone";
import { Toast } from 'vant';
export default {
  name: "App",
  components: {

  },
  mounted() {
    //自动登录
    if (checkPersonLogin()) {
      let user = getPersonAutoLoginData();
      this.$api.post("/PersonAccount/Login", { loginType: 5, userName: user.username, passWord: user.password }).then((res) => {
        if (res.success) {
          setToken(res.response.token);
          this.$chathub.init(this.$root,res.response.personID,res.response.token);
          returnToPhoneWithData({ action: 'person_im_login', personid: res.response.personID })
        }
      });
    }
    if (checkCompanyLogin()) {
      let user = getCompanyAutoLoginData();
      this.$api.post('/CompanyAccount/Login', { userName: user.username, passWord: user.password }).then(res => {
        if (res.success) {
           setToken(res.response.token);
          this.$chathub.init(this.$root,res.response.companyID,res.response.token);
          returnToPhoneWithData({ action: 'company_im_login', companyid: res.response.companyID })
        }
      })
    }
  },
};
</script>

<style lang="less">
@import "vant/lib/nav-bar/index.less";

body {
  background-color: #f4f5f7;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

p {
  margin: 0;
}

b {
  font-weight: 500;
}

.content-top {
  margin-top: @nav-bar-height;
}

ul,
li,
dl,
dt,
dd {
  padding: 0;
  margin: 0;
}
</style>
